%
%

% data_file_name    - name of .mat file containing animation (which was
% previously loaded from C3D
% ascii_            - TRUE/FALSE, specify whether the .mat file is in ASCII
% trgl_filename     - the name of the .obj file, which contains correct
% triangulation of the subject
% target_name       - pattern of name for exported OBJs
function [] = exportFaceOBJs(data_file_name, ascii_, trngl_filename, target_name)

if(ascii_)
    anim_data = load(data_file_name, '-ascii');
else
    anim_data = load(data_file_name);
end % IF

frame_num = size(anim_data, 1);

[v, faces] = read_wobj(trngl_filename);

%{
match = vertexMatch(orig, orig);
nFaces = size(faces,1);
for i = 1:nFaces
    for j = 1:3
        faces(i,j) = match( faces(i,j) );
    end
end % for
%}

fName = [target_name '-'];
for i = 1 : frame_num
    LOG(['Exporting frame ' int2str(i)]);
    fIndex = int2str(i);
    if ( i < 10) 
        fIndex = strcat( '0', int2str(i) ); 
    end % IF   
    
    fileName = strcat( strcat( fName, fIndex), '.obj' );
    exportOBJ(fileName, toMatrix( anim_data(i,:)), faces);
end % for

end % function





